// 时间相关 API（遵循项目现有 baseService 风格）
import baseService from "@/service/baseService";
import appService from "@/service/appService";
import type { IHttpResponse } from "@/types/interface";

export interface IServerTimeData {
  now?: string | number;
  timestamps?: string | number;
}
export interface IServerTimeResponse extends IHttpResponse {
  data: IServerTimeData | string | number;
}

export const timeApi = {
  /**
   * 获取服务器当前时间（毫秒）
   * GET timestamps/current
   * - 跳过签名，避免循环依赖
   */
  getCurrent(): Promise<IServerTimeResponse> {
    // 跳过签名，避免循环依赖；后端可能返回字符串时间戳
    return baseService.get("timestamps/current", undefined, { __skipSign: true }) as Promise<IServerTimeResponse>;
  },
  /**
   * 获取App端当前时间戳（毫秒）
   * GET platform/time
   * - 跳过签名，避免循环依赖
   */
  getAppCurrent(): Promise<IServerTimeResponse> {
    return appService.get("platform/time", undefined, { __skipSign: true }) as Promise<IServerTimeResponse>;
  },
   
  getAppCurrents(): Promise<IServerTimeResponse> {
    return appService.get("platform/time", undefined, { __skipSign: true }) as Promise<IServerTimeResponse>;
  }
};
